<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件的冒泡</title>
    <style>
        #box1{
            width: 200px;
            height: 200px;
            background-color: yellowgreen;
        }
        #s1{
            background-color: #FF8F00;
        }
    </style>
    <script>
        window.onload=function () {
            var s1=document.getElementById("s1");
                s1.onclick=function (event) {
                    event=event||window.event;
                    event.cancelBubble=true;//取消冒泡
                alert("我是span点击响应函数");
                };
            var box1=document.getElementById("box1");
                box1.onclick=function (event) {
                    event=event||window.event;
                    event.cancelBubble=true;//取消冒泡
                alert("我是box1单击响应函数");
                };
            document.body.onclick=function () {
                alert("我是body的单击响应函数");
            };
        }


    </script>
</head>
<body>
<script>
    /*事件冒泡
      *      事件的向上传导，当后代元素上的事件被触发时，其祖先元素的相同事件也会被触发
      *取消冒泡
    *
    *
    *
    * */
</script>
<div id="box1">
    我是box1
    <span id="s1">我是span</span>
</div>
</body>
</html>